# Maintainer: dan.saul <aur@cryingwolf.org>
pkgname=ude-switch
pkgver=7
pkgrel=1
pkgdesc="A simple switch configuration program for asterisk."
arch=(any)
depends=('asterisk16' 'python2')
license=('MIT')
makedepends=('subversion') 
url='http://code.google.com/p/ude-switch/'
install=ude-switch.install
backup=('etc/ude/switch/database.ini' 'etc/ude/switch/extensions.gen.ael')

_svntrunk=http://ude-switch.googlecode.com/svn/trunk/
_svnmod=ude-switch-read-only

build() {
	cd "${srcdir}"
	if [ -d ${_svnmod}/.svn ]; then
		(cd ${_svnmod} && svn up -r ${pkgver})
	else
		svn co ${_svntrunk} --config-dir ./ -r ${pkgver} ${_svnmod}
	fi
	
	msg "SVN checkout done or server timeout"
	
	install -Dm600 "${srcdir}/ude-switch-read-only/database.ini" "${pkgdir}/etc/ude/switch/database.ini"
	install -Dm644 "${srcdir}/ude-switch-read-only/generate-extensions.ael.py" "${pkgdir}/usr/share/ude/switch/generate-extensions.ael.py"
	install -Dm644 "${srcdir}/ude-switch-read-only/sip.conf.py" "${pkgdir}/usr/share/ude/switch/sip.conf.py"
	install -Dm644 "${srcdir}/ude-switch-read-only/voicemail.conf.py" "${pkgdir}/usr/share/ude/switch/voicemail.conf.py"
	
	install -Dm644 "${srcdir}/ude-switch-read-only/extensions.ael" "${pkgdir}/etc/ude/switch/extensions.ael"
	install -Dm644 "${srcdir}/ude-switch-read-only/extensions.gen.ael" "${pkgdir}/etc/ude/switch/extensions.gen.ael"
	install -Dm644 "${srcdir}/ude-switch-read-only/sip.conf" "${pkgdir}/etc/ude/switch/sip.conf"
	install -Dm644 "${srcdir}/ude-switch-read-only/voicemail.conf" "${pkgdir}/etc/ude/switch/voicemail.conf"
	install -Dm644 "${srcdir}/ude-switch-read-only/cdr_pgsql.conf" "${pkgdir}/etc/ude/switch/cdr_pgsql.conf"
	
	mkdir -p ${pkgdir}/etc/asterisk/
	ln -s /etc/ude/switch/voicemail.conf ${pkgdir}/etc/asterisk/voicemail.conf
	ln -s /etc/ude/switch/sip.conf ${pkgdir}/etc/asterisk/sip.conf
	ln -s /etc/ude/switch/extensions.ael ${pkgdir}/etc/asterisk/extensions.ael
	ln -s /etc/ude/switch/extensions.gen.ael ${pkgdir}/etc/asterisk/extensions.gen.ael
	ln -s /etc/ude/switch/cdr_pgsql.conf ${pkgdir}/etc/asterisk/cdr_pgsql.conf
}
